//
//  DateFormatTests.swift
//  UtilityTests
//
//  Created by yuhus on 2023/11/2.
//

import Foundation
import XCTest
import Nimble

final class DateFormatTests: XCTestCase {
  func testUnitsStyle() throws {
    let formatter = DateComponentsFormatter()
    
    expect(formatter.string(from: 300)).to(equal("5:00"))
    
    formatter.unitsStyle = .positional // 0
    expect(formatter.string(from: 300)).to(equal("5:00"))
    
    formatter.unitsStyle = .abbreviated
    expect(formatter.string(from: 300)).to(equal("5m"))

    formatter.unitsStyle = .short
    expect(formatter.string(from: 300)).to(equal("5 min"))
    
    formatter.unitsStyle = .full
    expect(formatter.string(from: 300)).to(equal("5 minutes"))
    
    formatter.unitsStyle = .spellOut
    expect(formatter.string(from: 300)).to(equal("five minutes"))
    
    formatter.unitsStyle = .brief
    expect(formatter.string(from: 300)).to(equal("5min"))
    
    let min: TimeInterval = 60
    let hr: TimeInterval = min * 60
    let day: TimeInterval = 24 * hr
    formatter.unitsStyle = .abbreviated
    print(formatter.string(from: day * 3 + hr * 5 + min * 43 + 45))
  }
}
